﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace pLib
{
    /// <summary>
    /// 
    /// </summary>
    public class MyProcess
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public MyProcess()
        {

        }
        /// <summary>
        /// create process
        /// example: createProcess("path\1.bat");
        /// </summary>
        /// <param name="path"></param>
        public void createProcess(string path)
        {
            try
            {
                Process proc = new Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName = path;
                proc.Start();
            }
            catch (Exception ex)
            {
                
            }
        }

        /// <summary>
        /// start application
        /// startApplication("IExplorer.exe");
        /// </summary>
        /// <param name="applicationName"></param>
        public void startApplication(string applicationName)
        {
            try
            {
                Process.Start(applicationName);
            }
            catch (Exception ex)
            {
                
            }
        }
        /// <summary>
        /// start application with start info, example 
        /// startApplicationWithStartInfo("IExplorer.exe","www.net.com")
        /// </summary>
        /// <param name="applicationName"></param>
        /// <param name="argument"></param>
        public void startApplicationWithStartInfo(string applicationName, string argument)
        {
            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(applicationName);
            startInfo.WindowStyle = ProcessWindowStyle.Normal;

            Process.Start(startInfo);

            startInfo.Arguments = argument;

            Process.Start(startInfo);

            }
            catch (Exception ex)
            {
                
            }
        }
    }
}
